package sample.entity;

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.image.ImageView;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Colmuns {
    private ImageView image;
    private StringProperty field;
    private StringProperty type;
    private StringProperty length;
    private StringProperty is_null;
    private StringProperty key;
    private StringProperty sdefault;
    private StringProperty extra;
    private StringProperty comment;

    public Colmuns(ImageView image, String field, String type, String is_null, String key, String sdefault, String extra, String comment) {
        String length = "0";
        String pattern = "(\\D*)(\\d+)";
        // 创建 Pattern 对象
        Pattern r = Pattern.compile(pattern);
        // 现在创建 matcher 对象
        Matcher m = r.matcher(type);
        if (m.find()) {
            System.out.println("Found value: " + m.group(0));
            System.out.println("Found value: " + m.group(1));
            System.out.println("Found value: " + m.group(2));
            length = m.group(2);
            String group = m.group(1);
            String replace = group.replace("(", "");
            type = replace;
            System.out.println("Found value: " + replace);
        } else {
            System.out.println(type);
            System.out.println("NO MATCH");
        }

        this.image = image;
        this.field = new SimpleStringProperty(field);
        this.length = new SimpleStringProperty(length);

        this.type = new SimpleStringProperty(type);
        this.is_null = new SimpleStringProperty(is_null);
        this.key = new SimpleStringProperty(key);
        this.sdefault = new SimpleStringProperty(sdefault);
        this.extra = new SimpleStringProperty(extra);
        this.comment = new SimpleStringProperty(comment);
    }

    public String getField() {

        return field.get();
    }

    public void setField(String field) {
        this.field.set(field);
    }

    public ImageView getImage() {
        return image;
    }

    public void setImage(ImageView image) {
        this.image = image;
    }

    public StringProperty fieldProperty() {
        return field;
    }

    public String getType() {
        return type.get();
    }

    public void setType(String type) {
        this.type.set(type);
    }

    public StringProperty typeProperty() {
        return type;
    }

    public String getLength() {
        return length.get();
    }

    public void setLength(String length) {
        this.length.set(length);
    }

    public StringProperty lengthProperty() {
        return length;
    }

    public String getIs_null() {
        return is_null.get();
    }

    public void setIs_null(String is_null) {
        this.is_null.set(is_null);
    }

    public StringProperty is_nullProperty() {
        return is_null;
    }

    public String getKey() {
        return key.get();
    }

    public void setKey(String key) {
        this.key.set(key);
    }

    public StringProperty keyProperty() {
        return key;
    }

    public String getSdefault() {
        return sdefault.get();
    }

    public void setSdefault(String sdefault) {
        this.sdefault.set(sdefault);
    }

    public StringProperty sdefaultProperty() {
        return sdefault;
    }

    public String getExtra() {
        return extra.get();
    }

    public void setExtra(String extra) {
        this.extra.set(extra);
    }

    public StringProperty extraProperty() {
        return extra;
    }

    public String getComment() {
        return comment.get();
    }

    public void setComment(String comment) {
        this.comment.set(comment);
    }

    public StringProperty commentProperty() {
        return comment;
    }
}
